package org.nf.shopping.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Picture;
import org.nf.shopping.service.PictureService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author czl
 * @Date 2024-12-27
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/picture")
public class PictureController extends BaseController{

    private final PictureService pictureService;

    @GetMapping("/listPicture")
    public ResultVO<PageInfo<Picture>> listPicture(Integer limit, Integer page, String name){
        PageInfo<Picture> pageInfo = pictureService.listPicture(limit, page, name);
        return success(pageInfo);
    }

    @PostMapping("/updatePicture")
    public ResultVO updatePicture(Picture picture){
        pictureService.updatePicture(picture);
        return success();
    }

    @PostMapping("/delonePicture")
    public ResultVO delonePicture(Integer id){
        pictureService.delonePicture(id);
        return success();
    }

    @PostMapping("/addPicture")
    public ResultVO addPicture(Picture picture){
        pictureService.addPicture(picture);
        return success();
    }

    @GetMapping("/getPictureList")
    public List<Picture> getPictureList(){
        return pictureService.getPictureList();
    }
}
